import { method } from "lodash";

/*
 * @Author: Quinn
 * @Date: 2023-05-19 11:40:35
 * @LastEditors: 叽歪小Q
 * @Description:
 */
const formatUrl = (url, data, config) => {
  return `${url}/${data.id}`;
};

const getList = [
  "/order/getOfferDirectoryDown",
  "/storeLedger/getFinanceOneLevelTypeDto",//财务列表获取费用类型
  "/storeLedger/selectFinanceDetailsByFinanceId",//财务列表获取费用类型明细
  "/inventory/getInventoryGoodsList",//根据仓库查看产品库存
  "role/roleList",
  "/material/getMaterialInfoLikeName",
  "/order/getOrderInfoLikeName",
  "/new/areaLedger/types",
  "/areaLedger/fyTypeList",
  "/areaLedger/areaList",
  "/factory/getFactoryList", //工厂列表
  "/new/areaLedger/list",
  "/new/storeLedger/stores",
  "/new/storeLedger/types",
  "/new/storeLedger/list",
  "/new/order/costs",
  "/new/finance/list",
  "/new/finance/reject/list",
  "/new/cad/parse/texts",
  "/new/cad/parse/result",
  "/new/afterSale/materials",
  "/material/inout/materials",
  "/new/order/out/materials",
  "/new/order/material/list",
  "/new/order/addition/list",
  "/new/order/storage/list",
  "/new/payment/list",
  "/afterSale/list",
  "/new/install/list",
  "/material/material/addition/list",
  "/new/province/enum",
  "/new/afterSaleTypes/enum",
  "/inStorage/inStorageList",
  "/areaLedger/areaLedgerList",
  "/storeLedger/storeLedgerList",
  "/areaLedger/areaListNew",//不受权限控制的仓库列表
  "/inventory/getLocationName",//库位列表
  "/user/userList",
  "/home/getHomeSellInfo",
  "/inventory/inventoryList",
  "/order/additionList",
  "/order/orderAdditionDetail",
  "/order/paymentDetials",
  "/order/installers",
  "/order/goodsDirectorys",
  "/order/orderAdditionDetail",
  "/user/userInfo",
  "/home/getHomeAfterSaleInfo",
  "/home/getHomePageInfo",
  "/check/checkList",//盘点列表
  "/purchase/getFactoryOutList",//查询工厂库存列表
  "/purchase/getAreaPutNum",//查询入库数量
  "/purchase/inspectPurchaseCompleteStatus",//查询采购订单是否已完成
  "/purchase/getFactoryInRecord",//查询修改库存记录

];
const postList = [
  "/user/userInfoUpdate",
  "/inventory/getInventoryList",
  "/user/deleteUser",
  "/user/addUser",
  "/afterSale/updateAfterSaleInfo",
  "/areaLedger/addAreaLedger",
  "/order/addPayment",
  "/order/insertAddition",
  "/new/areaLedger/create",
  "/new/storeLedger/create",
  "/new/storeLedger/update",
  "/new/finance/reject/update",
  "/new/finance/delete",
  "/new/afterSale/delete",
  "/factory/getFactoryMaterialList", //工厂库存列表
  "/factory/updateFactoryInventoryNum", //修改工厂库存
  "/factory/addFactoryMaterial", //添加工厂产品
  "/purchase/getPurchaseList", //采购单列表
  "/purchase/addPurchase", //新增采购单
  "/purchase/deductionFactoryInventory", //工厂出库扣减库存
  "/purchase/purchaseMaterialAddInventory", //操作入库
  "/order/updateOrderCadUserId",//cad操作认领
  "/order/orderList",
  // "/new/order/delete",
  "/order/orderDelete",
  "/single/addSingle",//单品出库新增
  "/single/getSingleList",//单品出库新增
  "/single/updateSingle",//单品出库编辑
  "/single/singleOutInventory",//单品出库扣库存
  "/allot/addAllotMaterial",//调货新增
  "/allot/getAllotMaterial",//调货列表
  "/allot/updateOutProofByAllotNo",//上传调出凭证
  "/allot/updateAllotMaterial",//编辑调货单
  "/allot/allotOutAndInInventory",//调货单确认完成
  "/check/checkAdd",//新增盘点单
  "/check/updateStatus",//改变盘点状态
  "/check/checkDelete",//删除
  "/inventory/updateLocationName",//编辑库位
  "/purchase/purchaseMaterialAddInventory",//采购单入库
  "/new/finance/update",
  "/new/afterSale/update",
  "/order/confirmOrder",//订单列表 确认订单锁库存
  "/order/outNew",//订单出库
  "/inventory/updateInventoryWarningNum",//订单出库
  "/purchase/updateDamageNum",//采购单仓库报损
  "/purchase/updateDamageStatus",//采购单工厂确认报损
  "/order/CancelRollbackInventory",//回滚订单列表库存
  "/order/getSmsSendRecordList",//短信预警列表
  "/new/install/create",
  "/new/afterSale/create",
  "/new/payment/create",
  "/new/order/create",
  "/new/order/update",
  "/new/order/out",
  "/new/cad/parse",
  "/order/orderInfoUpdate",
  "/order/addInstaller",
  "/afterSale/afterSaleAdd",
  "/storeLedger/updateStoreLedger",
  "/storeLedger/updateStoreLedgerStatus"
];

const initApi = (arr, method = "get") => {
  const res = {};
  arr.forEach((url) => {
    const key = url
      .split("/")
      .filter((e) => e)
      .map((str, index) => {
        if (index > 0) return str.slice(0, 1).toUpperCase() + str.slice(1);
        return str;
      })
      .join("");
    res[key] = {
      url,
      method,
    };
    if (method == "post") res[key]["contentType"] = "application/json";
  });
  return res;
};

export default {
  ...initApi(getList),
  ...initApi(postList, "post"),
  login: {
    url: "/user/login",
  },
  getAccountInfo: {
    url: "/account",
    method: "get",
    formatUrl,
  },
  deleteRole: {
    url: "/role",
    method: "delete",
    formatUrl,
  },
  addRole: {
    url: "/role",
    method: "post",
  },
  getRole: {
    url: "/role/roleList",
    method: "get",
  },
  patchRole: {
    url: "/role",
    method: "patch",
    formatUrl,
  },
  getLeaders: {
    url: "/account/managers/list",
    method: "get",
  },
  getAccount: {
    url: "/user/userList",
    method: "get",
  },
  updatePsd: {
    url: "/account/update_password",
    method: "post",
  },
  addAccount: {
    url: "/account",
    method: "post",
    contentType: "application/json",
  },
  setAccountRole: {
    url: "/account_role",
    method: "post",
    contentType: "application/json",
  },
  patchAccount: {
    url: "/account",
    method: "patch",
    formatUrl,
  },
  deleteAccount: {
    url: "/account",
    method: "delete",
    formatUrl,
  },
  getInventoryWarn: {
    url: "/material/inventory/alarm",
    method: "get",
  },
  getInventory: {
    url: "/inventory/getInventoryList",
    method: "post",
  },
  patchInventory: {
    url: "/material/inventory/update",
    method: "post",
    contentType: "application/json",
  },
  getInout: {
    url: "/inout/inOutRecordList",
    method: "post",
  },
  inoutUpdate: {
    url: "/order/out",
    contentType: "application/json",
    method: "post",
  },
  addInout: {
    url: "/material/inout",
    method: "post",
    contentType: "application/json",
  },
  addMaterial: {
    url: "/material",
    contentType: "application/json",
  },
  editMaterial: {
    url: "/material",
    contentType: "application/json",
  },
  patchMaterial: {
    url: "/material/updateMaterialStatus",
    method: "post",
    contentType: "application/json",
  },
  updateMaterial: {
    url: '/material/materialUpdate',
    method: 'post',
    contentType: "application/json"
  },
  deleteMaterial: {
    url: "/material/delMaterial",
    method: "post",
    contentType: "application/json",
  },
  qrcodeMaterial: {
    url: "/material/qrcode",
    method: "get",
  },
  getMaterial: {
    url: "/material/queryMaterialPage",
    method: "get",
  },
  getInstall: {
    url: "/order/install/list",
    method: "get",
  },
  getOrderQuotation: {
    url: "/order/quotation",
    method: "get",
  },
  getQuoteMaterials: {
    url: "/order/quotation/materials",
    method: "get",
  },
  createQuotation: {
    url: "/order/quotation",
    method: "post",
    contentType: "application/json",
    formatUrl,
  },
  getExtraOrder: {
    url: "/order/extraOrder",
    method: "get",
  },
  patchExtraOrder: {
    url: "/order/extraOrder",
    method: "post",
    contentType: "application/json",
    formatUrl,
  },
  orderList: {
    url: "/order/orderList",
    method: "post",
  },
  orderDetail: {
    url: "/order/detail",
    method: "get",
    formatUrl,
  },
  upload: {
    url: "/common/upload",
    method: "post",
    contentType: "multipart/form-data",
  },
  patchOrder: {
    url: "/order",
    method: "post",
    contentType: "application/json",
    formatUrl,
  },
  orderFlow: {
    url: "/order/orderFlow",
    method: "get",
  },
  orderLine: {
    url: "/order/order/line",
    method: "get",
  },
  addDirectory: {
    url: "/directory/addDirectory",
  },
  impInventoryExcel: {
    url: "/material/inventory/import/execl",
  },
  getDirectory: {
    url: "/directory/directoryList",
    method: "get",
  },
  patchDirectory: {
    url: "/directory/updateDirectory",
    method: "post",
    contentType: "application/json",
    // formatUrl,
  },
  deleteDirectory: {
    url: "/directory/deleteDirectory",
    method: "post",
  },
};
